import axios from '@/libs/axios.js'
import url from 'postcss-url'
import baseUrl from './index'
let jsonHeaders = {'content-type': 'application/json;charset=UTF-8'}

// 镜像列表
export const getImageData = (params,query) => {
    return axios({
        // url: `${baseUrl}/virtual/image/pageListData`,
        url:`${baseUrl}/resource-manager/image/list`,
        method: 'post',
        params:query,
        data:JSON.stringify(params),
        headers: jsonHeaders,
    })
}
// 获取Profile列表
export const getProfile = () => {
    return axios({
        // url: `${baseUrl}/virtual/profile/list/detial`,
        url: `${baseUrl}/resource-manager/profile/list/detail`,
        method: 'get',
        headers: jsonHeaders,
    })
}
// 修改镜像
export const modifyImg = (params) => {
    return axios({
        // url: `${baseUrl}/virtual/image/updateimage/${params.id}`,
        url:`${baseUrl}/resource-manager/image/update/${params.id}`,
        method: 'put',
        data:JSON.stringify(params.data),
        headers: jsonHeaders,
    })
}
// 删除镜像
export const deleteImage = (id) => {
    return axios({
        // url: `${baseUrl}/virtual/image/deleteimage/${id}`,
        url:`${baseUrl}/resource-manager/image/del/${id}`,
        method: 'delete',
        headers: jsonHeaders,
    })
}
// 根据ID查询镜像信息
export const getDetailByID = (id) => {
    return axios({
        // url: `${baseUrl}/virtual/image/imagedate/${id}`,
        url:`${baseUrl}/resource-manager/image/detail/${id}`,
        method: 'get',
        headers: jsonHeaders,
    })
}
// 查询镜像接入用户
export const getImageUserList = (id) => {
    return axios({
        // url: `${baseUrl}/virtual/ImageUser/list/${id}`,
        url:`${baseUrl}/resource-manager/image/access/list`,
        method: 'get',
        params: {
            imageId:id
        },
        headers: jsonHeaders,
    })
}
// 增加镜像接入
export const addAccess = (params) => {
    return axios({
        // url: `${baseUrl}/virtual/ImageUser/save`,
        url:`${baseUrl}/resource-manager/image/access`,
        method: 'post',
        data:params,
        headers: jsonHeaders,
    })
}
// 删除镜像接入
export const delAccess = (id) => {
    return axios({
        // url: `${baseUrl}/virtual/ImageUser/delete/${id}`,
        url:`${baseUrl}/resource-manager/image/access/${id}`,
        method: 'DELETE',
        headers: jsonHeaders,
    })
}
// 修改镜像接入
export const modifyAccess = (params) => {
    return axios({
        // url: `${baseUrl}/virtual/ImageUser/update/${params.id}`,
        url:`${baseUrl}/resource-manager/image/access/${params.id}`,
        method: 'PUT',
        data:params,
        headers: jsonHeaders,
    })
}
//合并镜像文件
export const mergeFiles = (formMerge)=>{
    return axios({
        method:'post',
        // url:`${baseUrl}/virtual/merge`,
        url:`${baseUrl}/resource-manager/upload/merge`,
        data:formMerge,
        headers:{
            'Content-type':'multipart/form-data',
        },
        timeout:0
    })
}

// 主动发起镜像校验
export const checkImage = (id) => {
    return axios({
        method: 'post',
        url: `${baseUrl}/resource-manager/image/verify/${id}`,
        headers:jsonHeaders
    })
}

//镜像系统版本列表
export const getImageType = params => {
  return axios({
    url: `${baseUrl}/resource-manager/image/imageType/list`,
    method: "get",
    params: params,
    headers: jsonHeaders
  });
};

//获取镜像要部署的平台类型
export const getImagePlatform = params => {
    return axios({
      url: `${baseUrl}/resource-manager/image/source/platform`,
      method: "get",
      params: params,
      headers: jsonHeaders
    });
  };
